package leetcode.d1;

import java.util.HashSet;
import java.util.Set;

/**
 * @author hang an
 * @since 2025/7/15
 */
public class R3136有效单词 {
    public boolean isValid(String word) {
        if (word == null) return false;
        Set<Character> set = new HashSet<>();
        set.add('a');
        set.add('e');
        set.add('i');
        set.add('o');
        set.add('u');
        set.add('A');
        set.add('E');
        set.add('I');
        set.add('O');
        set.add('U');
        boolean[] arr = new boolean[]{false, false};
        int length = word.length();
        if (length < 3) return false;
        char[] cs = word.toCharArray();
        for (char c : cs) {
            if ('a' <= c && c <= 'z' || 'A' <= c && c <= 'Z') {
                if (set.contains(c)) arr[0] = true;
                else arr[1] = true;
            } else if (!('0' <= c && c <= '9'))
                return false;
        }
        return arr[0] && arr[1];
    }
}
